package com.mvd.app.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.mvd.app.R;
import com.mvd.app.model.CarsInforModel;

import java.util.List;

/**
 * Created by leilei on 2022/12/16.
 */

public class TianjinAdapter extends BaseAdapter {
    private LayoutInflater mInflater;
    private Context context;
    private List<CarsInforModel> data;

    public TianjinAdapter( Context context, List<CarsInforModel> data) {
        this.context = context;
        this.data = data;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return data.size();
//        return 3;
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.tianjin_item,
                    null);
            holder.tjItemCarPlate = (TextView) convertView
                    .findViewById(R.id.tj_item_carPlate);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        if(data.get(position)!=null){
            String carPlate = data.get(position).getPlateRegion()+data.get(position).getPlateNO();
            holder.tjItemCarPlate.setText(carPlate);
        }else{
//            holder.tjItemCarPlate.setText("123");
        }
//        holder.tjItemCarPlate.setText("123");
        return convertView;
    }
    class ViewHolder {
        TextView tjItemCarPlate;
    }
}
